package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoInsertFill;
import com.sky.entity.Dish;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * The interface Dish mapper.
 */
@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     *
     * @param categoryId the category id
     * @return integer integer
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 查询菜品名称是否重复
     *
     * @param dishQuery the dish query
     * @return the integer
     */
    Integer selectCount(Dish dishQuery);

    /**
     * 新增菜品
     *
     * @param dish the dish
     */
    @AutoInsertFill
    void insert(Dish dish);

    /**
     * 菜品分页查询
     *
     * @param dish the dish
     * @return the page
     */
    Page<Dish> selectList(Dish dish);

    /**
     * 批量删除菜品
     *
     * @param ids the ids
     */
    void deleteById(List<Long> ids);

    /**
     * 起售中的菜品不能删除
     *
     * @param ids    the ids
     * @param status the status
     * @return the integer
     */
    Integer selectCountByIdsAndStatus(List<Long> ids, Integer status);

    /**
     * 查询菜品数据
     *
     * @param id the id
     * @return the dish
     */
    @Select("select * from dish where id = #{id}")
    Dish selectById(Long id);

    /**
     * 修改菜品数据
     *
     * @param dish the dish
     */
    @AutoInsertFill
    void updateById(Dish dish);
}
